package com.student.jpan;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.management.modelmbean.ModelMBean;
import javax.naming.InitialContext;
import javax.security.auth.login.AccountException;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import javax.xml.crypto.Data;

import com.mysqld.Mysqld;
import com.tools.Table;
import com.tools.Tools;

public class SstudentMan extends JPanel{
	
	int WIDTH;
	int HEIGH;
	String account;
	public SstudentMan(int width,int heigh,String account) {
		this.WIDTH=width;
		this.HEIGH=heigh;
		this.account=account;
		init();
	}
	void init() {
		this.setPreferredSize(new Dimension(WIDTH,HEIGH));
		
		Box boxHBox=Box.createVerticalBox();
		this.add(boxHBox);//建立垂直盒子
		
	
		

		
		Box box1=Box.createHorizontalBox();//设置水平资格
		boxHBox.add(Box.createVerticalStrut(20));
		boxHBox.add(box1);

	
		
		Box box2=Box.createHorizontalBox();//设置水平资格
		boxHBox.add(Box.createVerticalStrut(20));
		boxHBox.add(box2);
		

	
		
		

		JButton jButton3=new JButton("查找学生成绩");
		box2.add(jButton3);
		box2.add(Box.createHorizontalStrut(20));
		
		
		
		//____________________________________________________________________
		Object columns[] ={"学号","姓名","高等数学","数据结构","java课程"};
		Table t1Table=new Table(columns);//设置标题
		JTable table = t1Table.getTables();//获取表格
		JScrollPane JS = t1Table.getJScrollPane();//获取表格 滚动条
		DefaultTableModel model = t1Table.getModel();//获取表格控制
		JS.setPreferredSize(new Dimension(WIDTH-40,580));//设置整个滚动条窗口的大小
		this.add(JS);
		
		//__________________________________________________________________________________
		
		
		
		
		//查找
		jButton3.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
		
					String data[]= {account};
					Tools.setTableSize(table, WIDTH, Tools.addDataTable(Mysqld.QueryData("select account,name,proj1,proj2,proj3 from student where account=?",  data), model,5 ));
				
				
			}
		});
		
		
		
	}
	//初始化标签与文本
	void inil(String sr,Box box) {
		JLabel jLabel=new JLabel(sr);
		
		box.add(jLabel);
		box.add(Box.createHorizontalStrut(20));
	}
	JTextField init1(int h,Box box) {
		
		JTextField jTextField=new JTextField(h);
		box.add(jTextField);
		box.add(Box.createHorizontalStrut(20));
		return jTextField;
	}
	
	
	
}
